//
//  EFPickerView.m
//  EFHealth
//
//  Created by 舒鹏 on 16/8/29.
//  Copyright © 2016年 ef. All rights reserved.
//

#import "EFPickerView.h"

@interface EFPickerView ()<UIPickerViewDelegate,UIPickerViewDataSource>
@property(nonatomic,strong)NSArray *dataArr;
@property(nonatomic,assign)CGFloat rowHeight;
@end

@implementation EFPickerView

@synthesize dataArr = dataArr;
@synthesize rowHeight = rowHeight;
@synthesize selecTitle = selecTitle;

- (instancetype)initWithFrame:(CGRect)frame dataArray:(NSArray *)dataArray rowHeight:(CGFloat)height{

    self = [super initWithFrame:frame];
    
    dataArr = dataArray;
    rowHeight = height;
    
    self.delegate = self;
    self.dataSource = self;
    
    return self;
}

- (NSInteger)numberOfComponentsInPickerView:(UIPickerView *)pickerView{
    
    return 1;
}
- (NSInteger)pickerView:(UIPickerView*)pickerView numberOfRowsInComponent:(NSInteger)component
{
    return dataArr.count;
}
- (NSString*)pickerView:(UIPickerView*)pickerView titleForRow:(NSInteger)row forComponent:(NSInteger)component
{
    return dataArr[row];
}

- (CGFloat)pickerView:(UIPickerView*)pickerView rowHeightForComponent:(NSInteger)component
{
    return rowHeight;
}
- (void)pickerView:(UIPickerView*)pickerView didSelectRow:(NSInteger)row inComponent:(NSInteger)component
{
    selecTitle = dataArr[row];
}

@end
